<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>列表页</title>
    <link rel="stylesheet" href="/Public/css/bootstrap.min.css">
    <link rel="stylesheet" href="/Public/css/animate.min.css">
    <link rel="stylesheet" href="/Public/css/jquery.gDialog.css">
</head>
<body>
<!-- header start -->
<div class="jumbotron">
    <div class="container">
        <h1>CURD 练习</h1>
        <h2>——玩转表单</h2>
        <a href="<?php echo U('User/login');?>">登录</a>
        <h5>欢迎:<img height="50" src="/Public/pic/<?php echo I('session.name')['pic'];?>"> <font color="red"><?php echo I('session.name')['email'];?></font></h5>
        <a href="<?php echo U('User/logout');?>">退出</a>
    </div>
</div>
<!-- header end -->

<!-- content start -->
<div class="container content">
    <div class="row">
        <div class="sidebar col-md-3">
            <div class="list-group">
                <a href="#" class="list-group-item active">
                    学生列表
                </a>
                <a href="<?php echo U('Home/Index/add');?>" class="list-group-item ">
                    新增学生
                </a>
            </div>
        </div>
        <div class="main col-md-9">
         <!--  <div class="alert alert-success" role="alert">
                添加成功-1001
                <button type="button" class="close" data-dismiss="alert">
                    <span aria-hidden="true">&times;</span>
                    <span class="sr-only">Close</span>
                </button>
            </div>
 -->
            <form class="form-inline" role="form" action="<?php echo U('Home/Index/index');?>" method="get">
                <div class="input-group col-md-12">

                <div class="form-group col-md-3">
                        <input class="form-control " type="text" placeholder="姓名中包含" name="name" value="">
                </div>

                <div class="form-group col-md-3">
                        <input class="form-control " type="text" placeholder="最大年龄" name="maxage" value="">
                </div>

                <div class="form-group col-md-3">
                        <input class="form-control " type="text" placeholder="最小年龄" name="minage" value="">
                </div>
                        <input  type="radio" name="sex" value="m">男
                        <input  type="radio" name="sex" value="w">女
                        <select class="form-control " name="class">
                            <option value="">班级</option>
                            <option value="1">1</option>
                            <option value="2">2</option>
                            <option value="3">3</option>
                        </select>
                        <span class="input-group-btn">
                            <button class="btn btn-default" type="submit" value="查询">查询</button>
                        </span>
                    
                </div>
            </form>
            <br>
    
            

            <div class="panel panel-default">
                <!-- Default panel contents -->
                <div class="panel-heading">学生列表</div>
                <!-- Table -->
                <table class="table table-striped table-hover">
                    <tr class="th">
                        <td>编号</td>
                        <td>姓名</td>
                        <td>性别</td>
                        <td>年龄</td>
                        <td>班级</td>
                        <td>操作</td>
                    </tr>
                    <?php if(is_array($stu)): foreach($stu as $key=>$v): ?><tr>
                        <td><?php echo ($v['id']); ?></td>
                        <td><?php echo ($v['name']); ?></td>
                        <td><?php echo ($v['sex']); ?></td>
                        <td><?php echo ($v['age']); ?></td>
                        <td><?php echo ($v['class']); ?></td>
                        <td>
                           <!--  <a href="<?php echo U('Home/Index/detail');?>">详情</a> -->
                            <a href="<?php echo U('Home/Index/update',['id'=>$v['id']]);?>">编辑</a>
                            <a href="<?php echo U('Home/Index/del',['id'=>$v['id']]);?>" onclick="if(confirm('确定删除吗？')===false) return false">删除</a>
                        </td>
                    </tr><?php endforeach; endif; ?>

                </table>
            </div>
            <p>
            <font size="5px">
               <button class="up">上一页</button>
               <button class="down">下一页</button>
            </font>
            </p>

        </div>
    </div>
</div>
<!-- content end -->

<!--footer start-->
<div class="jumbotron" style="margin-bottom: 100px;">
    <div class="container">
        <h5>&copy;2017-09-25 by zx</h5>
    </div>
</div>
<!--footer end-->

<!-- script start -->
<script src="/Public/js/jquery-1.8.3.min.js"></script>
<script src="/Public/js/bootstrap.min.js"></script>
<script src="/Public/js/highlight.min.js"></script>
<script src="/Public/js/jquery.gDialog.min.js"></script>
<script src="/Public/js/holder.min.js"></script>
<!-- script end -->
<script>
    $(function(){
        var p=1;
        $(".down").click(function(){
            p++;
            var url="<?php echo U('Home/Index/index',I('get.'));?>";
            $.get(url,{p:p},function(tt){
                if (tt.status==1) {
                    $(".th").nextAll().remove();
                    $(".th").after(tt.data);
                }else{
                    p--;
                }               
                console.log(tt);
            });
        })
        $(".up").click(function(){
            p--;
            var url="<?php echo U('Home/Index/index',I('get.'));?>";
            $.get(url,{p:p},function(tt){
                if (tt.status==1) {
                    $(".th").nextAll().remove();
                    $(".th").after(tt.data);
                }else{
                    p++;
                }               
                console.log(tt);
            });
        })
    });
</script>

</body>
</html>